/**
 * 删除继承的属性及方法
 */
const fs = require('fs');
const fn = "C:\\users\\shuaihu\\miniui2.json";
s = fs.readFileSync(fn, "utf8");
obj = JSON.parse(s);
function chksupper(o, v) {
    if (o._osupper)
        if (o._osupper[v] && o[v] == o._osupper[v])
            return true;
        else
            return chksupper(o._osupper, v);
    return false;
}
function cleardup(obj) {
    let buf = [];
    for (var x in obj) {
        if (x == '_supper' || x == "constructor") {
            continue;
        }
        if (typeof obj[x] === "object") {
            if (x.charAt(0) == "_" && x!='_osupper') {
                delete (obj[x]);
                console.log('deleted' + x)
                continue;
            }
            buf.push(obj[x]);
            continue;
        }
        if (chksupper(obj, x) || x.charAt(0) == '_') {
            delete (obj[x]);
            console.log("deleted " + x)
        }
    }
    buf.forEach((v) => {
        cleardup(v);
    })
}
cleardup(obj);
s = JSON.stringify(obj);
fs.writeFileSync("C:\\users\\shuaihu\\miniui1.json", s);
console.log('OK');
